const TOPIC_STATE = {
  page: 1,
  limit: 20,
  list: [],
  topicInfo: {},
  replies: [],
  admireState: false //点赞状态
}

export default function topicList(prestate=TOPIC_STATE, action) {
  switch (action.type) {
    case 'admireSuccess':
      return {...prestate, admireState: !prestate.admireState}
    case 'getTopicInfo':
      const replies = action.infoData.replies
      delete action.infoData.replies
      return {...prestate, replies, topicInfo: action.infoData}
    case 'getTopicList':
      return {...prestate, list: action.list, page: 1}
    case 'appendTopicList':
      return {...prestate, list: prestate.list.concat(action.list), page: action.page}
  
    default:
      return {...prestate}
  }
} 